<?php

namespace Wgx\Admin\Com\Crud\EditPageInput;

use Wgx\Admin\Com\Crud\EditPageInputBase;

class InputSelect extends EditPageInputBase
{
    /** @var array */
    private $optionMap;
    /** @var null|string */
    private $className;
    /** @var null|string */
    private $specParam;

    /**
     * InputSelect constructor.
     * @param array $optionMap - [key1 => val2, key2 => val2, ...]
     * @param mixed $origValue - 原值
     * @param null|string $className - 额外指定的 class
     * @param null|string $specParam - 额外指定的参数
     */
    public function __construct($optionMap, $origValue, $className = null, $specParam = null)
    {
        $this->optionMap = $optionMap;
        $this->origValue = $origValue;
        $this->className = $className;
        $this->specParam = $specParam;
    }

    /**
     * @inheritDoc
     */
    public function getInputType()
    {
        return self::InputSelect;
    }

    /**
     * @inheritDoc
     */
    public function getIsRequired()
    {
        return false;
    }

    /**
     * [key1 => val2, key2 => val2, ...]
     * @return array
     */
    public function getOptionMap()
    {
        return $this->optionMap;
    }

    /**
     * @param array $optionMap - [key1 => val2, key2 => val2, ...]
     * @return InputSelect
     */
    public function setOptionMap($optionMap)
    {
        $this->optionMap = $optionMap;
        return $this;
    }

    /**
     * 额外指定的 class
     * @return string|null
     */
    public function getClassName()
    {
        return $this->className;
    }

    /**
     * @param string|null $className - 额外指定的 class
     * @return InputSelect
     */
    public function setClassName($className)
    {
        $this->className = $className;
        return $this;
    }

    /**
     * 额外指定的参数
     * @return string|null
     */
    public function getSpecParam()
    {
        return $this->specParam;
    }

    /**
     * @param string|null $specParam - 额外指定的参数
     * @return InputSelect
     */
    public function setSpecParam($specParam)
    {
        $this->specParam = $specParam;
        return $this;
    }

}